package blog.caidabao.mapper;

import blog.caidabao.pojo.Article;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface ArticleMapper extends Mapper<Article> {
    @Select(" SELECT id, article.article_title articleTitle, article_view_times articleViewTimes,article.article_category_id articleCategoryId, article.create_time createTime FROM article")
    List<Article> articleAll();

    @Select(" SELECT id, article_title articleTitle FROM article ORDER BY id DESC LIMIT 0,8 ")
    List<Article> newestArticles();

    @Select(" SELECT MAX(id) FROM article ")
    Integer getLastInsertId();

    @Select(" SELECT id,article_title articleTitle,create_time createTime " +
            " FROM article where article_title like #{searchContent}")
    List<Article> search(String searchContent);

    @Select(" SELECT COUNT(id) FROM article  ")
    Integer count();

    @Select(" SELECT id,article_title articleTitle,create_time createTime FROM article LIMIT #{pageNum} , 10 ")
    List<Article> getArticleByPage(Integer pageNum);
}
